package com.foreknow.practice.impl.impl2;

public class ClassB implements InterfaceA {
        int sum = 1;

    @Override
    public int method(int n) {

        if (n < 0) {//判断传入数是否为负数
            throw new IllegalArgumentException("必须为正整数!");//抛出不合理参数异常
        }
        for (int i = 1; i <= n; i++) {//循环num
            sum *= i;//每循环一次进行乘法运算
        }
        return sum;//返回阶乘的值

    }
}
